package com.yangjun.controller.report;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.yangjun.service.report.InventoryReprotExportService;
import com.yangjun.vo.report.InventoryReportExportVO;

@RestController
@RequestMapping(value="/excel/inventory")
public class InventoryReportController {
	
	@Autowired
	private InventoryReprotExportService inventoryReprotExportService;

	@ResponseBody
	@RequestMapping("/getDeminsion")
	public Object getDeminsion(@RequestParam(value="reportid")String reportid,@RequestParam(value="userid")String userid){
		return inventoryReprotExportService.getDeminsion(reportid,userid);
	}
	@ResponseBody
	@RequestMapping("/getManufacturer")
	public Object getManufacturer(){
		return inventoryReprotExportService.getManufacturer();
	}
	@ResponseBody
	@RequestMapping("/getProvider")
	public Object getProvider(){
		return inventoryReprotExportService.getProvider();
	}
	@ResponseBody
	@RequestMapping("/getSearchTemplate")
	public Object getSearchTemplate(@RequestParam(value="dataType")String analysisType,@RequestParam(value="searchName")String searchName){
		return inventoryReprotExportService.querySearch(analysisType,searchName);
	}
	@ResponseBody
	@RequestMapping("/getTarget")
	public Object getTarget(@RequestParam(value="userid")String userid,@RequestParam(value="dataType")String dataType,@RequestParam(value="selectTarget")String[] targetSelectData){
		return inventoryReprotExportService.queryTarget(userid,dataType,targetSelectData);
	}	
	@ResponseBody
	@RequestMapping("/queryData")
	public Object queryData(InventoryReportExportVO itreVO){
		System.out.println("查询数据接口："+itreVO);
//		itreVO.setDataType("purchReturn");
//		itreVO.setBatchno("");
//		itreVO.setSearchName("providername");
//		String[] wareCode = new String[]{"81397","81431"};
//		String[] manufacturer = new String[]{"上海薇慕网络科技有限公司"};
//		itreVO.setSearchValue(manufacturer);
//		
//		
//		itreVO.setBeginDate("2016-11-15");
//		itreVO.setEndDate("2017-11-15");
//		//采购入库
//		String[] target = new String[]{"piIntime","piSheetcode","piSheettype","piWarecode","piWarename","piGspcategory","piRegistrationnumber","piUnitcode","piModel","piBatchno","piProductiondate","piExpireddate","piManufacturername","piProvidercode","piProvidername","piIncount","piGoodqty","piQcqty","piPendingreason","piCreator","piCreatime","piChecker","piChecktime","piRemark"};
//		//采购退货出库
//		String[] target = new String[]{"prOuttime","prSheetcode","prSheettype","prWarecode","prWarename","prGspcategory","prRegistrationnumber","prUnitcode","prModel","prBatchno","prProductiondate","prExpireddate","prManufacturername","prProvidercode","prProvidername","prReturncount","prCreator","prCreatime","prChecker","prChecktime","prRemark"};
//				
//		itreVO.setTarget(target);
		return inventoryReprotExportService.queryData(itreVO);
	}
	@ResponseBody
	@RequestMapping("/queryDataByReportId")
	public Object queryDataByReportid(@RequestParam(value="reportid")String reportid){
		System.out.println("根据ID查询数据接口："+reportid);
		return inventoryReprotExportService.queryData(reportid);
	}
	@ResponseBody
	@RequestMapping("/addReport")
	public Object addReport(InventoryReportExportVO itreVO){
		System.out.println("加入报表："+itreVO);
		return inventoryReprotExportService.addOrUpdateReport(itreVO);
	}
	@ResponseBody
	@RequestMapping("/addDownloadTaskByReportId")
	public Object addDownloadTaskByReportId(@RequestParam(value="reportid")String reportid,HttpServletRequest request){
		System.out.println("根据ID加入下载列表："+reportid);
		return inventoryReprotExportService.addDownloadTask(reportid,request);
	}	
	
	@ResponseBody
	@RequestMapping("/addDownloadTask")
	public Object addDownloadTask(InventoryReportExportVO itreVO,HttpServletRequest request){
//		itreVO.setDataType("purchReturn");
//		itreVO.setBatchno("");
//		itreVO.setSearchName("providername");
//		String[] wareCode = new String[]{"81397","81431"};
//		String[] manufacturer = new String[]{"上海薇慕网络科技有限公司"};
//		itreVO.setSearchValue(manufacturer);
//		
//		
//		itreVO.setBeginDate("2016-11-15");
//		itreVO.setEndDate("2017-11-15");
//		//采购入库
//		String[] target = new String[]{"piIntime","piSheetcode","piSheettype","piWarecode","piWarename","piGspcategory","piRegistrationnumber","piUnitcode","piModel","piBatchno","piProductiondate","piExpireddate","piManufacturername","piProvidercode","piProvidername","piIncount","piGoodqty","piQcqty","piPendingreason","piCreator","piCreatime","piChecker","piChecktime","piRemark"};
//		//采购退货出库
//		String[] target = new String[]{"prOuttime","prSheetcode","prSheettype","prWarecode","prWarename","prGspcategory","prRegistrationnumber","prUnitcode","prModel","prBatchno","prProductiondate","prExpireddate","prManufacturername","prProvidercode","prProvidername","prReturncount","prCreator","prCreatime","prChecker","prChecktime","prRemark"};
//				
//		itreVO.setTarget(target);
//		System.out.println("加入下载列表："+itreVO);
		return inventoryReprotExportService.addDownloadTask(itreVO,request); 
	}
}
